# Contributor: Holger Jaekel <holger.jaekel@gmx.de>
# Maintainer:
pkgname=aws-c-event-stream
pkgver=0.3.2
pkgrel=0
pkgdesc="AWS C99 implementation of the vnd.amazon.eventstream content-type"
url="https://github.com/awslabs/aws-c-event-stream"
# s390x: aws-c-common
# arm*, ppc64le: aws-c-io
arch="all !armhf !armv7 !ppc64le !s390x"
license="Apache-2.0"
makedepends="
	aws-c-cal-dev
	aws-c-common-dev
	aws-c-io-dev
	aws-checksums-dev
	cmake
	openssl-dev
	s2n-tls-dev
	samurai
	"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/awslabs/aws-c-event-stream/archive/refs/tags/v$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	CFLAGS="$CFLAGS -flto=auto" \
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure -j${JOBS:-2}
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

dev() {
	default_dev
	amove usr/lib/aws-c-event-stream
}

sha512sums="
295ee4b1f647f5b15790e000cd5f0102e64ef03912c1c7378739f52229b82090384c66367c4caf8fa7f34f3275b3da71bc031cf6000053ad31d53ce075721da2  aws-c-event-stream-0.3.2.tar.gz
"
